public class demo1 {
    public int[] singleNumber1(int[] nums) {
        int sum=0;
        for(int temp:nums){
            sum^=temp;
        }
        int ret1=0,ret2=0;
        //找到最低位
        int dift=0;
        while(true){
            if(((sum>>dift)&1)==1)break;
            else dift++;
        }
        for(int temp:nums){
            if(((temp>>dift)&1)!=0){
                ret1^=temp;
            }else{
                ret2^=temp;
            }
        }
        return new int[]{ret1,ret2};
    }
    public int[] singleNumber2(int[] nums) {
        int sum=0;
        for(int temp:nums){
            sum^=temp;
        }
        int ret1=0,ret2=0;
        sum = sum&-sum;
        for(int temp:nums){
            if((sum&temp)!=0){
                ret1^=temp;
            }else{
                ret2^=temp;
            }
        }
        return new int[]{ret1,ret2};
    }
    public int[] singleNumber(int[] nums) {
        int sum=0;
        for(int temp:nums){
            sum^=temp;
        }
        int ret1=0,ret2=0;
        //找到最低位
        int dift=0;
        while(true){
            if(((sum>>dift)&1)==1)break;
            else dift++;
        }
        for(int temp:nums){
            if(((temp>>dift)&1)!=0){
                ret1^=temp;
            }else{
                ret2^=temp;
            }
        }
        return new int[]{ret1,ret2};
    }

}
